package chapter10.practice24;

/**
 * 实现一个模板控制器
 * 通过控制器控制一定时间触发事件
 * Created by yangliwei on 2017/10/23.
 */
public abstract class Event {
    private long eventTime;
    protected final long delayTime;

    public Event(long delayTime) {
        this.delayTime = delayTime;
        start();
    }

    public void start() {
        eventTime = System.nanoTime() + delayTime;
    }

    public boolean ready() {
        return eventTime -System.nanoTime()<0;
    }

    public abstract void action();

}
